package com.mjduan.project.goodExample;

/**
 * Hans 2017-09-16 20:22
 */
public class GreenTrafficLightState extends State {

    private TrafficLight trafficLight;

    public GreenTrafficLightState(TrafficLight trafficLight) {
        this.trafficLight = trafficLight;
    }

    @Override
    public void handleRequest() {
        System.out.println(getClass().getName() + ":Turning traffic green-light to yellow");
        trafficLight.setState(trafficLight.getYellowState());
    }

    @Override
    public String toString() {
        return "Traffic light is green";
    }
}
